package zx.x.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import zx.x.common.utils.PageUtils;
import zx.x.common.utils.R;
import zx.x.modules.sys.entity.ChildrenEntity;
import zx.x.modules.sys.service.ChildrenService;


/**
 * 
 *
 * @author x
 * @email x
 * @date 2022-02-24 16:25:38
 */
@RestController
@RequestMapping("x/children")
public class ChildrenController {
    @Autowired
    private ChildrenService childrenService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("x:children:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = childrenService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //  @RequiresPermissions("x:children:info")
    public R info(@PathVariable("id") Integer id){
		ChildrenEntity children = childrenService.getById(id);

        return R.ok().put("children", children);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //  @RequiresPermissions("x:children:save")
    public R save(@RequestBody ChildrenEntity children){
		childrenService.save(children);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //  @RequiresPermissions("x:children:update")
    public R update(@RequestBody ChildrenEntity children){
		childrenService.updateById(children);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //  @RequiresPermissions("x:children:delete")
    public R delete(@RequestBody Integer[] ids){
		childrenService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
